<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">
        
    </ui:define>

    <ui:define name="left">
       
    </ui:define>

    <ui:define name="right">
       
    </ui:define>

    <ui:define name="content">
        <style>
            .ui-state-highlight.ui-selected {
                color: blueviolet;
            }
        </style>
        <p:panel style="height: 250px">        
            <h:form id="viewPPForm" style="font-size: 85%">

                <p:messages />

                <h:panelGrid columns="3" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Purchase Plan by Period: "/>
                    <h:outputText value="#{prManagerBean.purchasePlan.datePurchasePlan}">
                        <f:convertDateTime pattern="MMMM dd, yyyy"/>
                    </h:outputText>
                    <p:commandButton update="viewPPForm" oncomplete="ppDialog.show();" image="ui-icon ui-icon-search" />    
                </h:panelGrid>
                <p:commandButton value="Next" action="#{prManagerBean.viewPurchasePlanDisplay()}"/>

            </h:form>
        </p:panel>
        
        <p:dialog header="Search Purchase Plan" widgetVar="ppDialog" hideEffect="explode" height="600" width="800">
            <h:form id="ppForm">
                <p:dataTable var="pp" value="#{prManagerBean.allPurchasePlan}"
                             emptyMessage="No Purchase Plan found with given criteria" selection="#{prManagerBean.purchasePlan}" selectionMode="single">

                    <p:column filterBy="#{pp.dateCreated}" 
                              headerText="Purchase Plan Date"
                              filterMatchMode="contains">
                        <h:outputText value="#{pp.datePurchasePlan}">
                            <f:convertDateTime pattern="MMMM dd, yyyy"/>
                        </h:outputText>
                    </p:column>

                </p:dataTable>
                <p:commandButton value="Select Purchase Plan" update="viewPPForm" oncomplete="ppDialog.hide()"/>
            </h:form>
        </p:dialog>
    </ui:define>

    <ui:define name="bottom">
       
    </ui:define>

</ui:composition>
